package com.ellricky.baselib.adapter.cla

import android.app.Activity
import android.text.TextUtils
import android.view.View
import android.widget.CheckBox
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView

import com.andr.common.ui.adapter.BaseRecyclerAdapter
import com.andr.common.ui.adapter.SmartViewHolder
import com.andr.common.util.EmptyUtil
import com.andr.common.util.StrUtil
import com.andr.common.util.ViewUtil
import com.ellricky.baselib.R
import com.ellricky.baselib.entity.new.StudentList
import com.ellricky.baselib.entity.student.StudentListEntity
import com.ellricky.baselib.listener.OnChooseSingleListener
import com.ellricky.baselib.util.GlideUtil

import de.hdodenhof.circleimageview.CircleImageView

class StuAddAdapter(val activity: Activity)
    : BaseRecyclerAdapter<StudentList>(R.layout.base_adapter_stu_add) {

     var choosePos = -1

    public override fun onBindViewHolder(holder: SmartViewHolder, model: StudentList, position: Int) {
        val itemView = holder.itemView

        val cb = itemView.findViewById<CheckBox>(R.id.cb)
        cb.isChecked = choosePos == position

//        // 头像
//        val iv = itemView.findViewById<CircleImageView>(R.id.ivPic)
//        val picUrl = model.headPic
//        if (!TextUtils.isEmpty(picUrl)) {
//            GlideUtil.into(activity, picUrl, iv)
//        }


        val tvName = itemView.findViewById<TextView>(R.id.tvName)
        // 姓名+性别
        var name = StrUtil.filterEmpty(model.clue_name)
        val sexName = StrUtil.filterEmpty(model.clue_sex)
        if (!EmptyUtil.isEmpty(sexName)) {
            name += "($sexName)"
        }
        tvName.text = name

        // 请假状态图标
//        val ivState = itemView.findViewById<ImageView>(R.id.ivStateLabel)
//        val leaveStatus = model.isLeave
//        if (StrUtil.isEquals("0", leaveStatus))
//            ivState.visibility = View.GONE
//        else
//            ivState.visibility = View.VISIBLE

        val baseHour = StrUtil.filterEmpty(model.basic_num)
        holder.text(R.id.tvBaseHour, if (EmptyUtil.isEmpty(baseHour)) "" else baseHour + "课时")

        val specialHour = StrUtil.filterEmpty(model.special_num)
        holder.text(R.id.tvSpecialHour, if (EmptyUtil.isEmpty(specialHour)) "" else specialHour + "课时")

        holder.text(R.id.tvBirth, StrUtil.filterEmpty(model.member_birthday))
        holder.text(R.id.tvAge, StrUtil.filterEmpty(model.clue_age))

//        val flChoose = holder.itemView.findViewById<FrameLayout>(R.id.flChoose)
//        flChoose.setOnClickListener {
//            if (ViewUtil.isFastDoubleClick()) return@setOnClickListener
//
//        }

    }
}
